cmake_minimum_required(VERSION 3.16)
project(test_wav2lip_cpp)

#set(CMAKE_CXX_STANDARD 17)

if (WIN32)
    #libtorch
    set(Torch_DIR ${CMAKE_SOURCE_DIR}/libs/win-x86_64/libtorch/share/cmake/Torch)
    find_package(Torch REQUIRED)
    message(STATUS "TORCH_LIBRARIES: ${TORCH_LIBRARIES}")

    #opencv
    set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/libs/win-x86_64/opencv-mobile-4.10.0-windows-vs2022/x64/x64/vc17/staticlib)
    find_package(OpenCV REQUIRED)
    option(USE_OPENCV "shared library support" TRUE)
    message(STATUS "OpenCV_LIBS: ${OpenCV_LIBS}")

elseif (UNIX)
    #libtorch
    set(Torch_DIR ${CMAKE_SOURCE_DIR}/libs/linux-x86_64/libtorch/share/cmake/Torch)
    find_package(Torch REQUIRED)
    message(STATUS "TORCH_LIBRARIES: ${TORCH_LIBRARIES}")

    #opencv
    set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/libs/linux-x86_64/opencv-mobile/lib/cmake/opencv4)
    find_package(OpenCV REQUIRED)
    option(USE_OPENCV "shared library support" TRUE)
    message(STATUS "OpenCV_LIBS: ${OpenCV_LIBS}")
endif ()
# 添加这行以处理CMAKE_BUILD_TYPE变量
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug)
endif()

set(INCLUDE_DIRS
        face_detection
)

set(GLOBAL_SRC
        main.cpp
        #        face_detection/ConvBlock.cpp
        #        face_detection/HourGlass.cpp
        #        face_detection/HourGlass.h
        #        face_detection/Fan.cpp
        #        face_detection/Fan.h
        #        face_detection/BaseModule.h
)

add_executable(test_wav2lip_cpp ${GLOBAL_SRC})
include_directories(${TORCH_INCLUDE_DIRS} ${INCLUDE_DIRS})
target_link_libraries(test_wav2lip_cpp ${TORCH_LIBRARIES} ${OpenCV_LIBS})
set_property(TARGET test_wav2lip_cpp PROPERTY CXX_STANDARD 14)
if (WIN32)
    add_custom_command(TARGET test_wav2lip_cpp POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy_directory
            ${CMAKE_SOURCE_DIR}/libs/win-x86_64/libtorch/lib
            $<TARGET_FILE_DIR:test_wav2lip_cpp>)
endif ()